package com.liuyi.netty.im.server.handle;

import com.liuyi.netty.im.commons.codes.CodeConst;
import com.liuyi.netty.im.server.handle.pipeline.LimProcessor;
import com.liuyi.netty.im.server.util.Pair;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;

/**
 * im 命令处理类
 *
 * @author Mr.Fmy
 * @since 2021-11-27
 */
public class LimComandService {

    private final static Map<CodeConst.Command, Pair<LimProcessor, ExecutorService>> M = new HashMap<>();

    public static void put(CodeConst.Command command, LimProcessor processor, ExecutorService executor) {
        M.put(command, new Pair<>(processor, executor));
    }

    public static Pair<LimProcessor, ExecutorService> get(CodeConst.Command command) {
        if (!M.containsKey(command)) {
            throw new IllegalArgumentException("Command Processor Not：" + command.name());
        }
        return M.get(command);
    }
}
